package com.zfh.cloud.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zfh.cloud.apis.UserFeignClient;
import com.zfh.cloud.pojo.Order;
import com.zfh.cloud.pojo.User;
import com.zfh.cloud.service.OrderService;
import com.zfh.cloud.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 小可乐
* @description 针对表【t_order】的数据库操作Service实现
* @createDate 2024-09-14 13:27:23
*/
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order>
    implements OrderService{

    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private UserFeignClient userFeignClient;

    @Override
    public User findUserByOrderId(Long OrderId) {
        Order order = orderMapper.selectById(OrderId);
        User user = userFeignClient.findUserByUserId(order.getUserid());
        return user;
    }

    /**
     * 根据userid查询order
     *
     * @param userId
     */
    @Override
    public Order findOrderByUserId(Long userId) {
        return orderMapper.selectByUserId(userId);
    }
}




